#pragma once

#include <functional>

class UdpSocketBase  {
public: 
	typedef  std::function<void(const uint8_t*, size_t, const struct sockaddr*)> CALL_BACK;
	typedef  std::function<void()> ON_CLOSE;
	typedef  std::function<void(int)> ON_SEND_FAILED;
public:
	virtual int Listen(const char* ip, uint16_t port, const CALL_BACK& onReceiveData) = 0;
	virtual int Listen(const char* ip, uint16_t port, const CALL_BACK& onReceiveData, const ON_CLOSE& onClose, const ON_SEND_FAILED& onSendFailed) = 0;
	virtual void Destroy() = 0;
	virtual ~UdpSocketBase(){}
public:
	virtual void Send(const uint8_t *data, size_t len, const struct sockaddr *addr) = 0;
	virtual void Send(const uint8_t *data, size_t len, const char* ip,  uint16_t port) = 0;
public:
	virtual const struct sockaddr *GetLocalAddress() const = 0;
	virtual std::string GetLocalIP() = 0;
	virtual uint16_t GetLocalPort() const = 0;
	virtual size_t GetRecvBytes() const = 0;
	virtual size_t GetSentBytes() const = 0;
};
